class ShouldBePayedKeepScaleTo4 < ActiveRecord::Migration
  def self.up
    change_column :designer_work_items, :should_be_payed, :decimal, :precision => 8, :scale => 4, :default => 0
    change_column :stages, :should_be_payed, :decimal, :precision => 8, :scale => 4, :default => 0
    change_column :projects, :payed_total_amount, :decimal, :precision => 8, :scale => 4, :default => 0
    change_column :projects, :paying_total_amount, :decimal, :precision => 8, :scale => 4, :default => 0
    change_column :projects, :paused_total_amount, :decimal, :precision => 8, :scale => 4, :default => 0
    DesignerWorkItem.all.each do |designer_work_item|
      designer_work_item.reset_should_be_payed!
      designer_work_item.save
    end
  end

  def self.down
    change_column :designer_work_items, :should_be_payed, :decimal, :precision => 8, :scale => 2, :default => 0
    change_column :projects, :payed_total_amount, :decimal, :precision => 8, :scale => 2, :default => 0
    change_column :projects, :paying_total_amount, :decimal, :precision => 8, :scale => 2, :default => 0
    change_column :projects, :paused_total_amount, :decimal, :precision => 8, :scale => 2, :default => 0
  end
end
